home *** CD-ROM | disk | FTP | other *** search
/ TeX 1995 July / TeX CD-ROM July 1995 (Disc 1)(Walnut Creek)(1995).ISO / macros / latex209 / contrib / multido / md-make.tex (.txt) < prev    next >
LaTeX Document  |  1993-01-11  |  2KB  |  62 lines

  1. %% md-make.tex  1992  tvz@Princeton.EDU
  2. %% Run Plain TeX or LaTeX on this file to create a macro file multido.tex
  3. %% from multido.doc, stripped of comments.
  4. %% This is basically a take-off from F. Mittelbach's docstrip.tex
  5. %% This macros can be used for stripping comments from any TeX file.
  6. %% Just change these two lines:
  7. \def\outfile{multido.tex}
  8. \def\infile{multido.doc}
  9. \catcode`\@=11
  10. \expandafter\ifx\csname @latexerr\endcsname\relax\else\let\end\@@end\fi
  11. \newread\@infile
  12. \newwrite\@outfile
  13. \def\typeout{\immediate\write16}
  14. \typeout{}
  15. \typeout{Preparing to make stripped macro file \outfile.}
  16. \immediate\openin1=\outfile\relax
  17. \ifeof1\else
  18.     \typeout{%
  19.         File `\outfile' exists and will be overwritten if in current directory!!!}
  20. \def\check@@OK#1#2\@nil{\ifx#1y\else\expandafter\end\fi}
  21. \typeout{Make `\outfile'? (y=yes, n=no)}
  22. \read16 to\OK
  23. \expandafter\check@@OK\OK\@nil
  24. \newif\ifflag
  25. {\catcode`\%=12\gdef\%{%}}
  26. \edef\@@percent{\%\%}
  27. \def\process@line{\expandafter\process@@line\inline\relax\relax\@nil}
  28. \def\process@@line#1#2#3\@nil{%
  29.   \def\temp{#1}%
  30.     \ifx\temp\%
  31.       \def\temp{#1#2}%
  32.         \ifx\temp\@@percent\owrite\inline\fi
  33.     \else
  34.       \owrite\inline
  35.     \fi}
  36. \def\owrite#1{\immediate\write\@outfile{#1}}
  37. \def\mo#1{\catcode`#1=12\relax}
  38. \def\sanitize{\mo\ \mo\\\mo\$\mo\&\mo\#\mo\^\mo\_\mo\%\mo\~\mo\}\mo\{}
  39. \def\stripfile{%
  40.   \begingroup
  41.   \sanitize
  42.   \endlinechar-1
  43.   \flagtrue
  44.   \loop
  45.   \read\@infile to\inline
  46.   \ifeof\@infile\flagfalse\fi
  47.     \ifflag
  48.   \process@line
  49.   \repeat
  50.   \endgroup}
  51. \immediate\openout\@outfile\outfile\relax
  52. \owrite{\%\% This is file `\outfile' generated on
  53.   <\the\year/\the\month/\the\day>.}
  54. \owrite{\%\% The original source file was `\infile'.}
  55. \owrite{\%\%}
  56. \immediate\openin\@infile\infile\relax
  57. \stripfile
  58. \immediate\closein\@infile
  59. \owrite{\%\%}%
  60. \owrite{\%\% End of file `\outfile'.}%
  61. \immediate\closeout\@outfile
  62.